package rhc.taskSchedule.entity.taskSchedule;

import java.util.HashMap;
import java.util.Map;

/**调度类型
 * @author lenovo
 *
 */
public enum ScheduleType {

	CRON_FOREVER("cronForever","cronForever","根据表达式定时启动不限次数"),
	CRON_NUMBER("cronNumber","cronNumber","根据表达式启动几次"),
	INTERVAL_FOREVER("intervalForever","inervalForever","间隔时间启动不限次数"),
	INTERVAL_NUMBER("intervalNumber","intervalNumber","间隔时间启动几次");
	
	public String typeName;
	
	public String typeCode;
	
	public String desc;
	
	ScheduleType(String typeName,String typeCode,String desc){
		this.typeName=typeName;
		this.typeCode=typeCode;
		this.desc=desc;
	}

	public String getTypeName() {
		return typeName;
	}

	public void setTypeName(String typeName) {
		this.typeName = typeName;
	}

	public String getTypeCode() {
		return typeCode;
	}

	public void setTypeCode(String typeCode) {
		this.typeCode = typeCode;
	}

	public String getDesc() {
		return desc;
	}

	public void setDesc(String desc) {
		this.desc = desc;
	}
	
	private static final Map<String,ScheduleType> CODE_TYPE=new HashMap<String,ScheduleType>();
	
	static{
		for(ScheduleType st:ScheduleType.values()){
			CODE_TYPE.put(st.typeCode, st);
		}
	}
	
	/**根据code获取调度类型
	 * @param code
	 * @return
	 */
	public static ScheduleType getTypeByCode(String code){
		return CODE_TYPE.get(code);
	}
}
